<?php

//首页控制器
namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;

class IndexControllers extends Controller
{
   
    public function index(Request $request)
    {
        //dd($request->server(),$request->cookie());
        return 1;
    }

    public function login(Request $request)
    {

        if($request->get('user')){
            session(['user'=>$request->get('user')]);
        }
        $user = session('user');
        //登录检测
        if(!empty($user)){
            //return redirect()->route('user');
          var_dump($request->server());//通过与nginx配合使用
        }
        return "请登录";
    }

    public function user()
    {
       $user = session('user');
       if(empty($user)){
           return redirect()->route('login');
       }
       var_dump($user);
    }


}
